package com.example.classcommunity3.dao;


import com.example.classcommunity3.model.Classtable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;

public interface ClasstableDao extends JpaRepository<Classtable,Long>{

    Classtable findByCSubCodeAndCStuAccount(String cSubCode, Long cStuAccount);

    List<Classtable> findByCStuAccount(Long account);

    Long countByCSubCode(String cSubCode);

    @Transactional
    @Modifying
    @Query(nativeQuery = true, value ="DELETE FROM classtable WHERE c_sub_code = ?1" )
    int deleteByCSubCode(String subCode);
}
